package com.itheima.message.listener;

import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "order-topic",
        consumerGroup = "message_service_group",
        selectorExpression = "message",
        consumeMode = ConsumeMode.ORDERLY)
//consumeMode = ConsumeMode.ORDERLY ,指定消费者要有序获取消息)
//selectorExpression = "" , 过滤tag标签,只接收tag="message"的消息
public class OrderMessageListener implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {

        System.out.println("message service : " + message);

        if ("3".equals(message)) {
            int i = 1 / 0;
        }
    }
}
